#include "HUD.h"
#include "source\Game.h"
//#include "SGD Wrappers\CSGD_TextureManager.h"


HUD::HUD(Player* p)
{
	player = p;
	hudTimer = 0.0f;
	hudAlpha = 100;

	grappleImageID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("Textures/Objects/GrappleHUD.png"));
	magnetImageID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("Textures/Objects/MagnetHUD.png"));
	fireImageID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("Textures/Objects/FireHUD.png"));
	frostImageID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("Textures/Objects/SnowflakeHUD.png"));
}


HUD::~HUD(void)
{
}


void HUD::Update(float deltaTime)
{
	if(hudTimer > 0.0f)
		hudTimer -= deltaTime;

	if(hudTimer >= 3.0f)
		hudAlpha = 255;

	if(hudTimer < 0.0f && hudAlpha != 128)
		hudAlpha -= (int)(155 * deltaTime);

	if(hudAlpha > 255)
		hudAlpha = 255;
	else if(hudAlpha < 100)
		hudAlpha = 100;
}


void HUD::Render(void)
{
	RECT background = {Game::GetInstance()->GetScreenWidth() - 289, 64, Game::GetInstance()->GetScreenWidth() - 69, 138};
	CSGD_Direct3D::GetInstance()->DrawRect(background, D3DCOLOR_ARGB(hudAlpha, 255, 255, 255));
	
	CSGD_TextureManager::GetInstance()->Draw(grappleImageID, background.left + 5, background.top + 5, 1.0f, 1.0f, (RECT*)0, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(hudAlpha, 255, 255, 255));
	CSGD_TextureManager::GetInstance()->Draw(magnetImageID, background.left + 79, background.top + 5, 1.0f, 1.0f, (RECT*)0, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(hudAlpha, 255, 255, 255));
	if(player->GetToolManager()->GetThermo().GetIsFire())
		CSGD_TextureManager::GetInstance()->Draw(fireImageID, background.left + 153, background.top + 5, 1.0f, 1.0f, (RECT*)0, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(hudAlpha, 255, 255, 255));
	else
		CSGD_TextureManager::GetInstance()->Draw(frostImageID, background.left + 153, background.top + 5, 1.0f, 1.0f, (RECT*)0, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(hudAlpha, 255, 255, 255));



	if(player->GetToolManager()->GetIsGrapple())
	{
		RECT grapple = {background.left + 5, background.top + 5, grapple.left + 64, grapple.top + 64};
		CSGD_Direct3D::GetInstance()->DrawHollowRect(grapple, D3DCOLOR_ARGB(hudAlpha, 0, 0, 255));
	}

	if(player->GetToolManager()->GetIsMagnet())
	{
		RECT magnet = {background.left + 79, background.top + 5, magnet.left + 64, magnet.top + 64};
		CSGD_Direct3D::GetInstance()->DrawHollowRect(magnet, D3DCOLOR_ARGB(hudAlpha, 0, 0, 255));
	}

	if(player->GetToolManager()->GetIsThermo())
	{
		RECT thermo = {background.left + 153, background.top + 5, thermo.left + 64, thermo.top + 64};
		CSGD_Direct3D::GetInstance()->DrawHollowRect(thermo, D3DCOLOR_ARGB(hudAlpha, 0, 0, 255));
	}
}
